package com.masterclient.app.modules.shop.adapter;

import android.view.View;
import android.widget.AdapterView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eoner.managerlibrary.router.AroutePath;
import com.masterclient.app.R;
import com.masterclient.app.modules.shop.beans.StoreClassifyGroupBean;
import com.masterclient.app.widget.NonScrollGridView;

/**
 * @auther hjian
 * @date 2020/4/8.
 */
public class StoreClassifyAdapter extends BaseQuickAdapter<StoreClassifyGroupBean, BaseViewHolder> {
    private String storeId;
    public StoreClassifyAdapter(String store_id) {
        super(R.layout.item_store_classify);
        storeId = store_id;
    }

    @Override
    protected void convert(BaseViewHolder helper, StoreClassifyGroupBean item) {
        helper.setText(R.id.item_store_classify_name, item.getName());
        NonScrollGridView gridView = helper.getView(R.id.item_store_classify_gridview);
        gridView.setAdapter(new StoreClassifyGridAdapter(mContext, item.getChilds()));
        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                ARouter.getInstance().build(AroutePath.STORE_SEARCH_ACTIVITY).withBoolean("isSearch",false)
                        .withString("title",item.getChilds().get(position).getName())
                        .withString("tag",item.getChilds().get(position).getTag()).withString("store_id",storeId).navigation();

            }
        });

        helper.getView(R.id.item_store_classify_ll).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ARouter.getInstance().build(AroutePath.STORE_SEARCH_ACTIVITY).withBoolean("isSearch",false)
                        .withString("title",item.getName()).withString("store_id",storeId)
                        .withString("tag",item.getTag()).navigation();
            }
        });

    }
}
